<%@ taglib uri="http://www.springframework.org/tags" prefix="spring" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>

<html lang="zh">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>文章审核</title>

    <!-- 引入Bootstrap CSS -->
    <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/css/bootstrap.min.css" rel="stylesheet">

    <!-- 自定义样式 -->
    <style>
        body {
            background-color: #f4f7fc;
            font-family: Arial, sans-serif;
            display: flex;
            min-height: 100vh;
            margin: 0;
        }

        /* 侧边栏样式 */
        .sidebar {
            width: 250px;
            background-color: #007bff;
            color: white;
            height: 100vh;
            position: fixed;
            top: 0;
            left: 0;
            padding-top: 20px;
            box-shadow: 2px 0px 5px rgba(0, 0, 0, 0.1);
        }

        .sidebar h2 {
            text-align: center;
            margin-bottom: 20px;
            font-size: 20px;
        }

        .sidebar a {
            display: block;
            padding: 12px;
            color: white;
            text-decoration: none;
            font-size: 16px;
        }

        .sidebar a:hover {
            background-color: #0056b3;
        }

        /* 页面主内容部分 */
        .main-content {
            margin-left: 250px;
            padding: 20px;
            flex-grow: 1;
        }

        h1 {
            text-align: center;
            margin-top: 20px;
            color: #343a40;
        }

        .table th, .table td {
            text-align: center;
            vertical-align: middle;
        }

        .table th {
            background-color: #007bff;
            color: white;
        }

        .table td {
            background-color: #ffffff;
        }

        .table-striped tbody tr:nth-of-type(odd) {
            background-color: #f9f9f9;
        }

        .table-hover tbody tr:hover {
            background-color: #e9ecef;
        }

        .form-group select,
        .form-group button {
            margin-top: 10px;
        }

        .alert-message {
            margin: 20px 0;
        }

        .back-link {
            display: block;
            margin-top: 20px;
            text-align: center;
            font-size: 1.1rem;
            color: #007bff;
        }

        .back-link:hover {
            color: #0056b3;
        }
    </style>
</head>

<body>
<!-- 侧边栏 -->
<div class="sidebar">
    <h2>超级管理员控制台</h2>
    <a href="/superAdmin/achievementReview">科研成果审核</a>
    <a href="/superAdmin/users">用户管理</a>
    <a href="/superAdmin/permissions/management">权限管理</a>
    <a href="/superAdmin/articleReview">文章审核</a>
    <a href="/logout">退出登录</a>
</div>


<!-- 页面主内容 -->
<div class="main-content">
    <div class="container">
        <h1>文章审核</h1>

        <!-- 显示审核结果消息 -->
        <c:if test="${not empty message}">
            <div class="alert alert-success alert-message">${message}</div>
        </c:if>
        <c:if test="${not empty error}">
            <div class="alert alert-danger alert-message">${error}</div>
        </c:if>

        <!-- 文章审核表格 -->
        <table class="table table-striped table-hover">
            <thead>
            <tr>
                <th>标题</th>
                <th>摘要</th>
                <th>状态</th>
                <th>操作</th>
            </tr>
            </thead>
            <tbody>
            <c:forEach var="article" items="${articles}">
                <tr>
                    <td>
                        <a href="<c:url value='/superAdmin/articleReview/${article.articleId}'/>">${article.title}</a>
                    </td>
                    <td>${article.abstractText}</td>
                    <td>
                        <c:choose>
                            <c:when test="${article.status == 0}">
                                <span class="badge bg-warning">审核中</span>
                            </c:when>
                            <c:when test="${article.status == 1}">
                                <span class="badge bg-success">已通过</span>
                            </c:when>
                            <c:when test="${article.status == 2}">
                                <span class="badge bg-danger">未通过</span>
                            </c:when>
                        </c:choose>
                    </td>
                    <td>
                        <c:choose>
                            <c:when test="${article.status == 0}">
                                <form action="<c:url value='/superAdmin/articleReview/${article.articleId}'/>" method="post">
                                    <div class="form-group">
                                        <select name="status" class="form-control" required>
                                            <option value="1">通过</option>
                                            <option value="2">拒绝</option>
                                        </select>
                                    </div>
                                    <button type="submit" class="btn btn-primary">提交审核</button>
                                </form>
                            </c:when>
                            <c:when test="${article.status == 1}">
                                <span class="text-success">无操作</span>
                            </c:when>
                            <c:when test="${article.status == 2}">
                                <form action="<c:url value='/superAdmin/articleReview/${article.articleId}/reject'/>" method="get">
                                    <button type="submit" class="btn btn-warning">修改拒绝理由</button>
                                </form>
                            </c:when>
                        </c:choose>
                    </td>
                </tr>
            </c:forEach>
            </tbody>
        </table>

    </div>
</div>

<!-- 引入Bootstrap JS 和依赖 -->
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/js/bootstrap.bundle.min.js"></script>
</body>
</html>
